package com.project.lk.nurseapp.nurse.doctorapply.presenter;

import com.project.lk.nurseapp.base.BaseApi;
import com.project.lk.nurseapp.base.BasePresenter;
import com.project.lk.nurseapp.base.ModelPresenterBridge;
import com.project.lk.nurseapp.nurse.doctorapply.model.DoctorItemBean;
import com.project.lk.nurseapp.nurse.doctorapply.model.DoctorListModel;
import com.project.lk.nurseapp.nurse.doctorapply.model.DoctorTypeBean;
import com.project.lk.nurseapp.nurse.doctorapply.model.DoctorTypeModel;

import java.util.List;
/**
 * 功能介绍：
 * 项目名：
 * 模块名称：
 * 作者：LK
 * 日期：2018/1/9
 * 修改日期：
 */
public class DoctorListPresenter extends BasePresenter<IDoctorListView> implements ModelPresenterBridge{

    DoctorTypeModel typeModel;
    DoctorListModel listModel;
    public DoctorListPresenter(IDoctorListView view){
    addView(view);
    typeModel=new DoctorTypeModel();
    listModel=new DoctorListModel();
    typeModel.setBridge(this);
    listModel.setBridge(this);
    }

    public void loadTypeData(String url){
        typeModel.postLoadJson(url);
    }

    public List<DoctorTypeBean> getTypeList(){
        return typeModel.getmList();
    }

    public List<DoctorItemBean> getItemBeanList(){
        return listModel.getmList();
    }

    public void loadListData(String url,String departMentId){
        listModel.postLoadJson(url,departMentId);
    }
    public void refresh(String url,String sessionStatus){
        listModel.refresh();
        listModel.postLoadJson(url,sessionStatus);

    }

    public void loadMore(String url,String sessionStatus){
        listModel.loadMore();
        listModel.postLoadJson(url,sessionStatus);
    }

    @Override
    public void bridge(int action, List list) {
        if (view!=null) {
            switch (action){
                case BaseApi.show_list:
                    view.showList();
                    break;
                case BaseApi.fail:
                    view.showFail();
                    break;
                case BaseApi.noMore:
                    view.noMore();
                    break;
                case BaseApi.doctor_type_success:
                    view.typeListSuccess();
                    break;
                case BaseApi.doctor_type_fail:
                    view.typeFail();
                    break;
            }
        }
    }
}
